import { Application } from 'egg';

export default (app: Application) => {
  const { controller, router, config, middleware } = app;
  // const _jwt = middleware.jwtErr(app.config.jwt.secret); // 传入加密字符串
  // router.get('/', _jwt, controller.home.index); // 如果需要jwt则添加 _jwt
  const prefix = config.apiPrefix;
  router.post(`${prefix}/user/register`, controller.user.register);
  router.get(`${prefix}/user/info`, controller.user.getUserInfo);
  router.post(`${prefix}/user/login`, controller.user.login);
  router.post(`${prefix}/user/logout`, controller.user.logout);
  router.post(`${prefix}/user/dimission`, controller.user.dimission);
  router.get(`${prefix}/user/dept/list`, controller.user.getUserListByDept);
  router.post(`${prefix}/user/create`, controller.user.create);
  router.post(`${prefix}/user/save`, controller.user.save);
  router.post(`${prefix}/user/info/update`, controller.user.updateInfo);
  router.post(`${prefix}/user/password/update`, controller.user.updatePassword);
  // 表单分组
  router.post(`${prefix}/form/group/sort`, controller.form.sortGroup);
  router.get(`${prefix}/form/group/list`, controller.form.getGroupList);
  router.post(`${prefix}/form/group/create`, controller.form.createGroup);
  router.post(`${prefix}/form/group/rename`, controller.form.renameGroup);
  router.post(`${prefix}/form/group/remove`, controller.form.removeGroup);
  // 表单
  router.post(`${prefix}/form/sort`, controller.form.sortForm);
  router.get(`${prefix}/form/list`, controller.form.getFormList);
  router.post(`${prefix}/form/create`, controller.form.createForm);
  router.post(`${prefix}/form/rename`, controller.form.renameForm);
  router.post(`${prefix}/form/remove`, controller.form.removeForm);
  router.post(`${prefix}/form/save`, controller.form.saveForm);
  router.get(`${prefix}/form/get/data`, controller.form.getFormData);
  router.post(`${prefix}/form/biz/create`, controller.form.createFormBiz);
  router.get(`${prefix}/form/get/biz`, controller.form.getFormBiz);
  router.post(`${prefix}/form/biz/remove`, controller.form.removeFormBiz);
  router.post(`${prefix}/form/biz/save`, controller.form.saveFormBiz);
  // 流程
  router.post(`${prefix}/flows/open`, controller.flow.openFlow);
  router.post(`${prefix}/flows/close`, controller.flow.closeFlow);
  router.get(`${prefix}/flows/define`, controller.flow.getFlowDefine);
  router.post(`${prefix}/flows/save`, controller.flow.saveFlow);
  // 组织机构
  router.get(`${prefix}/org/list`, controller.org.getOrgList);
  router.post(`${prefix}/org/create`, controller.org.createOrg);
  router.post(`${prefix}/org/remove`, controller.org.removeOrg);
  router.post(`${prefix}/org/save`, controller.org.saveOrg);
};
